<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Full Layout - jQuery EasyUI Demo</title>
	<#include "./../common/header.html"/>
</head>
<body class="easyui-layout">
	<table id="dg" class="easyui-datagrid" title="机器信息" style="width:100%;height:68%"
		data-options="
				singleSelect: true,
				url:'${ctx}/schedule/loadMachineManager',
				toolbar: '#tb',
				pageSize:10,
				pagination:true,
				pageNumber:1,
			">
		<thead>
			<tr>
				<th data-options="field:'uuid',width:480">任务处理机</th>
				<th data-options="field:'start',width:100">状态</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="update_machine()">恢复/停止</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="load_StrategyRunntime()">查看任务分配情况</a>
	</div>
				
	<table id="strategyRunntime" class="easyui-datagrid" title="" style="width:100%;height:30%"
		data-options="
				title:'此调度器上的任务分配情况',
				singleSelect: true,
				url:'',
			">
		<thead>
			<tr>
				<th data-options="field:'strategyName',width:150">策略名称</th>
				<th data-options="field:'uuid',width:400">处理机器</th>
				<th data-options="field:'requestNum',width:100">线程组数量</th>
				<th data-options="field:'message',width:200">错误信息</th>
			</tr>
		</thead>
	</table>
</body>
<script>

function update_machine(){
	var row = $("#dg").datagrid('getSelected');
	if(row!=null){
	$.ajax({ url: "${ctx}/schedule/updateMachineInfo?uuid="+row.uuid+"&isStart="+row.start, success: function(response){
					var data= $.parseJSON(response); 
					if(response=='true'){
						$("#dg").datagrid('reload');
					}
				}});
	
	} else {
		$.messager.alert({
			title : '提示',
			msg : "请选择一行"
		});
	}
}

function load_StrategyRunntime(){
	var row = $("#dg").datagrid('getSelected'); 
	if(row!=null){
		 var handler='${ctx}/schedule/loadScheduleStrategyRunntime?uuid='+row.uuid;
		 $('#strategyRunntime').datagrid('options').url = handler;
         $('#strategyRunntime').datagrid('reload');
	} else {
		$.messager.alert({
			title : '提示',
			msg : "请选择一行"
		});
	}
}
</script>
</html>